/****************************************************************************/
/*                                                                          */
/*      SVPWM Driver                                                        */
/*                                                                          */
/*      Last updated by:  CBS                                               */
/*      Last update date: 12/12/25                                          */
/*      Revision:         0                                                 */
/*      Copyright:        DENSO                                             */
/*                                                                          */
/****************************************************************************/

/****************************************************************************/
/*  include files                                                           */
/****************************************************************************/

/*  version check                                                           */
#if !(((SVPWM_SW_MAJOR_VERSION == 1) && (SVPWM_SW_MINOR_VERSION == 0)) )
#error "Svpwm: Configuration file version differs from BSW version."
#endif /* version check */

#ifndef SVPWM_CFG_H_
#define SVPWM_CFG_H_

/****************************************************************************/
/*  defines / data types / structs / unions / macros                        */
/****************************************************************************/
#define SVPWM_DEV_ERROR_DETECT            STD_OFF        /* SVPWM 003a 003b */

/* Currently not supported. Must be implemented by user */
#define SVPWM_NOTIFICATION_SUPPORTED      STD_OFF        /* SVPWM 112  113  */
                                                
#define SVPWM_DUTYCYCLE_UPDATED_ENDPERIOD STD_ON
#define SVPWM_PERIOD_UPDATED_ENDPERIOD    STD_ON

#define SVPWM_DE_INIT_API                 STD_ON         /* SVPWM 080a 080b */
#define SVPWM_VERSION_INFO_API            STD_ON         /* SVPWM 069a 069b */

#define SVPWM_UPDATE_DUTYCYCLES_API       STD_ON         /* SVPWM 202a 202b */

/* Following definitions are not defined in AUTOSAR.                        */
#if 0
#define SVPWM_ISR_PRIORITY                (1)     /* To Implement Interrupt */
#endif /* 0 */

#define SVPWM_PRESCALER                   ((U4)0x02)

#define SVPWM_FREEZE_ENABLE               STD_ON

#define SVPWM_PHASE_DELAY                 (8)

#define SVPWM_APHASE_DEFAULT_DUTY         ((U4)0x6000)
 
#define SVPWM_BPHASE_DEFAULT_DUTY         ((U4)0x4000)

#define SVPWM_CPHASE_DEFAULT_DUTY         ((U4)0x2000)

#define SVPWM_PERIOD                      ((U4)500)

#define SVPWM_PERIOD_MODIFIED             (SVPWM_PERIOD + 27)

/* Channel Operation Mode */
#define SVPWM_EMIOS_OPWM 0x21
#if 0
#define SVPWM_EMIOS_OPWM 0x20
#define SVPWM_EMIOS_OPWM 0x22
#define SVPWM_EMIOS_OPWM 0x23
#endif  /* 0 */

/****************************************************************************/
/*  variables                                                               */
/****************************************************************************/
typedef enum {
    SVPWM_CHANNEL_0 = (U1)0,
    SVPWM_CHANNEL_1 = (U1)1,
    SVPWM_CHANNEL_2 = (U1)2,
    SVPWM_CHANNEL_3 = (U1)3,
    SVPWM_CHANNEL_4 = (U1)4,
    SVPWM_CHANNEL_5 = (U1)5,
    SVPWM_NUMBER_OF_CHANNELS = 6
} Svpwm_NamedChannelsType;

typedef U2 Svpwm_ChannelType;                                  /* SVPWM106 */

typedef U4 Svpwm_PeriodType;                                   /* SVPWM107 */

typedef U4 Svpwm_NotificationHandlerType;
typedef enum {
    SVPWM_CHANNEL_PRESCALER_1 = 0,
    SVPWM_CHANNEL_PRESCALER_2 = 1,
    SVPWM_CHANNEL_PRESCALER_4 = 3,
    SVPWM_CHANNEL_PRESCALER_8 = 7
} Svpwm_ChannelPrescalerType;

/****************************************************************************/
/* Configuration Structures                                                 */
/****************************************************************************/
typedef struct {
    U4    duty:32;               /* Number of duty ticks SVPWM070           */
    U4    period:32;             /* Length of period, in ticks SVPWM070     */
    U4    counter:32;            /* Counter                                 */
    U4    freezeEnable:1;        /* Enable freezing channel                 */
    U4    outputDisable:1;       /* Disable output                          */
    U4    outputDisableSelect:2; /* Select which bus disables the bus       */
    U4    prescaler:2;           /* Prescaler Value                         */
    U4    usePrescaler:1;        /* Enable prescaler                        */
    U4    useDma:1;              /* Enable DMA                              */
    U4    reserved_2:1;
    U4    inputFilter:4;         /* Input filter                            */
    U4    filterClockSelect:1;   /* Input filter clock source               */
    U4    flagEnable:1;          /* Enable interrupts/flags on this channel */
    U4    reserved_3:3;
    U4    forceMatchA:1;         /* Trigger a match on channel A            */
    U4    forceMatchB:1;         /* Trigger a match on channel B            */
    U4    reserved_4:1;
    U4    busSelect:2;           /* Use the internal counter                */
    U4    edgeSelect:1;          /* What edges to flag on?                  */
    U4    edgePolarity:1;        /* Polarity of the channel                 */
    U4    mode:7;                /* EMIOS mode                              */
} Svpwm_ChannelRegisterType;

typedef struct {
    Svpwm_ChannelRegisterType r;
    Svpwm_ChannelType channel;
} Svpwm_ChannelConfigurationType;


typedef struct 
{
    Svpwm_ChannelConfigurationType Channels[SVPWM_NUMBER_OF_CHANNELS];
    #if SVPWM_NOTIFICATION_SUPPORTED == STD_ON
    Svpwm_NotificationHandlerType NotificationHandlers[SVPWM_NUMBER_OF_CHANNELS];
    #endif /* SVPWM_NOTIFICATION_SUPPORTED */
} Svpwm_ConfigType;                                             /* SVPWM111 */

#endif 
/**** End Of File ***********************************************************/